package cn.sample.system.mapper;

import cn.sample.system.bean.Resource;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <h2></h2>
 *
 * <p></p>
 *
 * @author HKD
 */
@Mapper
public interface ResourceMapper extends BaseMapper<Resource> {

    @Select("SELECT * FROM system_resource WHERE id in (SELECT srr.res_id FROM system_role_resource srr WHERE srr.role_id in (\n" +
            "SELECT sur.role_id FROM system_user_role sur WHERE sur.user_id = #{uid}))")
    List<Resource> getResourceByUserId(Long uid);
}
